package com.kejiguan.ui.adapter;

import android.content.Context;
import android.database.DataSetObserver;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import com.kejiguan.ui.R;
import com.kejiguan.ui.model.SheduleTypeModel;

/**
 * Created by apple on 16/5/12.
 */
public class SheduleTimeTypeAdapter implements SpinnerAdapter{

    private LayoutInflater inflater;
    private SheduleTypeModel[] sheduleTypeModels;

    public SheduleTimeTypeAdapter(Context context,SheduleTypeModel[] sheduleTypeModels)
    {
        inflater=LayoutInflater.from(context);
        this.sheduleTypeModels=sheduleTypeModels;
    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        SheduleTypeModel sheduleTypeModel=sheduleTypeModels[position];
        View itemView=inflater.inflate(R.layout.dialog_shedule_time_type_layout,null);
        TextView timeNameView= (TextView) itemView.findViewById(R.id.time_name);
        timeNameView.setText(sheduleTypeModel.getTypeName());
        return itemView;
    }

    @Override
    public void registerDataSetObserver(DataSetObserver observer) {

    }

    @Override
    public void unregisterDataSetObserver(DataSetObserver observer) {

    }

    @Override
    public int getCount() {
        return sheduleTypeModels.length;
    }

    @Override
    public Object getItem(int position) {
        return sheduleTypeModels[position];
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        SheduleTypeModel sheduleTypeModel=sheduleTypeModels[position];
        View itemView=inflater.inflate(R.layout.dialog_shedule_time_type_layout1,null);
        TextView timeNameView= (TextView) itemView.findViewById(R.id.time_name);
        timeNameView.setText(sheduleTypeModel.getTypeName());
        return itemView;
    }

    @Override
    public int getItemViewType(int position) {
        return 0;
    }

    @Override
    public int getViewTypeCount() {
        return 1;
    }

    @Override
    public boolean isEmpty() {
        return false;
    }
}
